<?php

function getUpdateArr($rs) {
    if ($rs != true) {
        $arr = array(
            "code" => "update_fail",
            "result" => "修改失败，请稍后再试！",
        );
    } else {
        $arr = array(
            "code" => 0,
            "result" => "ok",
        );
    }
    return $arr;
}

function getInsertArr($rs) {
    if ($rs > 0) {
        $arr = array(
            "code" => 0,
            "result" => "ok",
            "lastid" => $rs
        );
    } else {
        $arr = array(
            "code" => "add_fail",
            "result" => "添加失败，请稍后再试！",
        );
    }
    return $arr;
}

function unsetArr($arr, $fields) {
    $fieldsArr = explode(",", $fields);
    if ($arr && $fieldsArr) {
        foreach ($fieldsArr as $v2) {
            unset($arr[$v2]);
        }
    }
    return $arr;
}

function getGoodsAttr($ids) {
    $rs = "";
    if ($ids) {
        $attrs = M("goods_attr")->field("name")->where("id in (" . $ids . ")")->order("ord ASC,id DESC")->select();
        foreach ($attrs as $v) {
            $attr_names[] = $v['name'];
        }
        $rs = implode(",", $attr_names);
    }
    return $rs;
}

?>
